package com.yanqu.road.server.manager.activity.hsisland.task;

import com.yanqu.road.logic.helper.ActivityHelper;
import com.yanqu.road.server.manager.activity.hsisland.CrossHsIslandActivity;
import com.yanqu.road.server.manager.activity.hsisland.CrossHsIslandActivityMgr;
import com.yanqu.road.utils.executor.GeneralTask;

import java.util.Map;

/**
 * 海神岛战场清理定时任务
 */
public class CrossHsIslandBattleFieldCleanTask extends GeneralTask {

    @Override
    public void doRun() {
        Map<Integer, Map<Integer, CrossHsIslandActivity>> activityMap = CrossHsIslandActivityMgr.getActivityMap();
        if (activityMap == null || activityMap.isEmpty()) {
            return;
        }
        for (Map<Integer, CrossHsIslandActivity> crossHsIslandActivityMap : activityMap.values()) {
            for (CrossHsIslandActivity activity : crossHsIslandActivityMap.values()) {
                try {
                    if (activity.getConfig() != null && !ActivityHelper.activityInShowTime(activity.getConfig().getActivityInfo())) {
                        continue;
                    }
                    activity.battleFieldCleanTask();
                } catch (Exception e) {
                    getLOGGER().error("battleFieldCleanTask error : ", e);
                }
            }
        }
    }
}
